package com.tcsl.exercise.demo.entity;

import java.util.List;

public class R <T> {
    private static String SUCCESS = "OK";
    private static Integer SUCCESSCODE = 0;
    private static String FAIL = "ERR";
    private static Integer FAILCODE = 1;
    private static Integer NO_DATA_CODE = 2;
    private static String NO_DATA = "NO_DATA";

    private String msg;
    private Integer code;
    private T data;

    public String getMsg() {
        return msg;
    }

    public R setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public R setCode(Integer code) {
        this.code = code;
        return this;
    }

    public static R ok(){
        R r = new R();
        r.setMsg(SUCCESS);
        r.setCode(SUCCESSCODE);
        return r;
    };
    public static R err(){
        R r = new R();
        r.setMsg(FAIL);
        r.setCode(FAILCODE);
        return r;
    };

    public T getData() {
        return data;
    }

    public R setData(T data) {
        this.data = data;
        return this;
    }

    public static R nodata(){
        R r = new R();
        r.setMsg(NO_DATA);
        r.setCode(NO_DATA_CODE);
        return r;
    }
}
